<template>
  <div class="div">
    <p>精品歌单 <svg class="icon cc"
           aria-hidden="true">
        <use xlink:href="#icon-wenhao"></use>
      </svg></p>
    <ul class="main">
      <li class="item"
          v-for="(item) in Highquality"
          :key="item.id">
        <router-link :to="{path:'/homeitem/:id',query:{id:item.id}}"> <img v-lazy="item.coverImgUrl"
               :key="item.coverImgUrl">
          <div class="m-num"
               v-if="item.playCount!==0">
            <svg class="icon "
                 aria-hidden="true">
              <use xlink:href="#icon-bofang"></use>
            </svg>
            <span class="num">{{ changeNum(item.playCount) }}</span>
          </div>
          <div class="left">
            <span class="name">{{ item.name }}</span>
            <span class="author">by&#8197;&#8197;{{ item.creator.nickname}}</span>
            <img v-lazy="item.creator.avatarDetail.identityIconUrl"
                 alt=""
                 v-if="item.creator.avatarDetail">
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import { getHighquality } from "@/api/RankList"

export default {
  data () {
    return {
      Highquality: [],//精品歌单列表
      queryInfo: {
        cat: '',
      }
    }
  },
  mounted () {
    this.queryInfo.cat = this.$route.query.cat
    this.getHighquality(this.queryInfo.cat)
  },
  methods: {
    // 获取精品歌单
    async getHighquality (queryInfo) {
      let res = await getHighquality(queryInfo)
      if (res.code !== 200) return
      this.Highquality = res.playlists
    },
    changeNum (num) {
      if (num >= 100000000) {
        return (num / 100000000).toFixed(1) + '亿'
      } else if (num > 10000) {
        return (num / 10000).toFixed(1) + '万'
      } else {
        return num
      }
    },
  }
}
</script>

<style scoped lang="less">
.div {
  width: 100%;
  p {
    margin-top: 30px;
    margin-left: 50px;
    margin-bottom: 10px;
    display: inline-block;
    font-weight: bold;
    font-size: 20px;
    .icon {
      width: 20px;
      height: 20px;
    }
  }
  .main {
    margin-left: 50px;
    .item {
      width: 400px;
      height: 160px;
      display: block;
      float: left;
      margin-right: 10px;
      position: relative;
      img {
        display: block;
        float: left;
        width: 140px;
        height: 140px;
        border-radius: 8px;
      }
      .m-num {
        width: auto;
        height: auto;
        position: absolute;
        top: 5px;
        left: 75px;
        color: #fff;
        font-size: 12px;
      }
      .left {
        margin-top: 20px;
        padding-left: 10px;
        float: left;
        width: 260px;
        span {
          display: block;
          height: 20px;
          font-size: 14px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        .author {
          font-size: 13px;
          float: left;
          color: rgb(154, 149, 149);
        }
        img {
          margin-left: 3px;
          margin-top: 1px;
          float: left;
          width: 13.5px;
          height: 14px;
        }
      }
    }
  }
}
</style>